#pragma once
#include <vector>
#include <fstream>
#include <string>

class mesh
{
private:
    std::vector<std::vector<double>> mesh_points;         // 创建2维数组
    std::vector<std::vector<unsigned int>> elem_topo;     // 网格节点拓扑
    std::vector<std::vector<int>> neighborElem;  // 附近的网格
    std::vector<std::vector<int>> neighborNodes; // 附近的节点
    std::vector<unsigned int> bottom_boundary;
    std::vector<unsigned int> top_boundary;
    std::vector<unsigned int> left_boundary;
    std::vector<unsigned int> right_boundary;

    std::string _type;
    unsigned int _points_num;
    unsigned int _elem_num;
    unsigned int _nx;
    unsigned int _ny;
    double _xmax;
    double _ymax;
    const unsigned int dim = 2;

public:
    ~mesh();
    mesh(const std::string &type = "Quadrilateral", const unsigned int nx = 30, const unsigned int ny = 40, const double xmax = 3.1415926,
         const double ymax = 3);
    void generateMesh();
    void getNeighborElem();
    void getNeighborNodes();
    unsigned int returnPointsNum();
    unsigned int returnElemNum();

    std::vector<std::vector<int>> returnNeighborNodes();
    std::vector<std::vector<double>> retrunMesh_points(); 
    std::vector<unsigned int> return_bottom_boundary();
    std::vector<std::vector<unsigned int>> return_elem_topo(); 
    std::vector<unsigned int> return_top_boundary();
    std::vector<unsigned int> return_left_boundary();
    std::vector<unsigned int> return_right_boundary();

    void getTop();
    void getBottom();
    void getLeft();
    void getRight();
    void saveMesh(); // 存储网格
    void readMesh(); // 未实现
};
